

import { createApp } from 'vue'
import { createPinia } from 'pinia'

import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import LogicFlow from "@logicflow/core";
import { Control } from "@logicflow/extension";
import globalScanner from './utils/globalScanner'; // 导入全局扫码服务
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
LogicFlow.use(Control);
const app = createApp(App)

// 初始化全局扫码服务
app.config.globalProperties.$scanner = globalScanner;

app.use(ElementPlus, {
    locale: zhCn,
})
app.use(createPinia().use(piniaPluginPersistedstate))
app.use(router)

app.mount('#app')

// 启动扫码服务
globalScanner.init();

// 在应用卸载时销毁扫码服务
window.addEventListener('beforeunload', () => {
  globalScanner.destroy();
});
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
